/*
 * @Description: 入口文件
 * @Author:
 * @Date: 2022-03-21 16:58:41
 * @LastEditTime: 2022-12-06 10:42:51
 */
import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import App from './App.vue'
import router from './router'
import store from './store'
import 'element-plus/dist/index.css'
import '@/styles/nprogress.scss' // 页面切换进度条
import '@/styles/main.scss'
import '@/styles/color.scss'
import '@/styles/style_black.scss'
import '@/styles/map.scss'
import '@/router/permissions' // 路由拦截
// import '@/mock/index' // 模拟数据 mockJs会导致地图无法正常加载 注释掉入口就好
import '@mdi/font/css/materialdesignicons.css'

const app = createApp(App)

/**
 * @desc: 自定义指令 判断按钮权限
 */
app.directive('permission', (el, binding) => {
  const role = binding.value
  const roles = store.getters['user/roles']
  if (roles.some((r) => r.code === role)) {
    // eslint-disable-next-line no-param-reassign
    el.style.display = 'inline-flex'
  } else {
    // eslint-disable-next-line no-param-reassign
    el.style.display = 'none'
  }
})

app.use(router).use(store).use(ElementPlus, { locale: zhCn }).mount('#app')
